package co.edu.usbcali.prototipobeta.modelo.dto;

import co.edu.usbcali.prototipobeta.modelo.Vacuna;
import co.edu.usbcali.prototipobeta.presentation.backingBeans.VacunaView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class VacunaDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String vacNombre;
    private String vacId;
    private boolean rowSelected = false;
    private VacunaView vacunaView;
    private Vacuna vacuna;

    public Vacuna getVacuna() {
        return vacuna;
    }

    public String listener_update(ActionEvent e) {
        try {
            vacunaView.action_modifyWitDTO(((vacId == null) ||
                vacId.equals("")) ? null : new Long(vacId),
                ((vacNombre == null) || vacNombre.equals("")) ? null
                                                              : new String(
                    vacNombre));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        vacId = vacuna.getVacId().toString();
        vacNombre = (vacuna.getVacNombre() != null)
            ? vacuna.getVacNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        vacId = vacuna.getVacId().toString();
        vacNombre = (vacuna.getVacNombre() != null)
            ? vacuna.getVacNombre().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setVacuna(Vacuna vacuna) {
        this.vacuna = vacuna;
    }

    public VacunaView getVacunaView() {
        return vacunaView;
    }

    public void setVacunaView(VacunaView vacunaView) {
        this.vacunaView = vacunaView;
    }

    public String getVacNombre() {
        return vacNombre;
    }

    public void setVacNombre(String vacNombre) {
        this.vacNombre = vacNombre;
    }

    public String getVacId() {
        return vacId;
    }

    public void setVacId(String vacId) {
        this.vacId = vacId;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
